This is a partial port from nullUtil 2.x.